#!/user/bin/python
# -*- coding: utf-8 -*-
'''
 @Time    : 2018/5/3 20:02
 @File    : run.py
 @desc    :
'''
from commonSpiders.net.server.flask.server import SocketIoApp
from commonSpiders.net.server.flask.server_run import FlaskRun
from commonSpiders.scrapy_clusters_manager.namespace.socketio_server_namespace import CrawlerProcessNamespace, \
    ClientSystemInfoNamespace, CrawlerTaskNamespace
from commonSpiders.scrapy_clusters_manager.service.manager_service import CrawlerManagerService
from commonSpiders.scrapy_clusters_manager.service.task_service import CrawlerTaskService

if __name__ == '__main__':
    app = SocketIoApp('commonSpiders.scrapy_clusters_manager.settings')
    app.socketio.on_namespace(CrawlerProcessNamespace(CrawlerProcessNamespace.KEY))
    app.socketio.on_namespace(ClientSystemInfoNamespace(ClientSystemInfoNamespace.KEY))
    app.socketio.on_namespace(CrawlerTaskNamespace(CrawlerTaskNamespace.KEY))
    FlaskRun(app, [CrawlerManagerService(), CrawlerTaskService()]).run()